<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title></title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/layuiadmin/style/admin.css" media="all">
    <style>
        .layui-form-item .layui-input-inline {
            width: 360px;
        }
    </style>
</head>
<body layadmin-themealias="default">

<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body" pad15="">
                    <div class="layui-form" wid100="" lay-filter="">
                        <input type="hidden" name="id" value="{$live_store.id}">
                        <div class="layui-form-item">
                            <label class="layui-form-label">商品类型</label>
                            <div class="layui-input-inline">
                                <select name="type" lay-filter="type_sel">
                                    <option value="2" {$live_store.type==2?'selected':''}>实物</option>
                                    <option value="1" {$live_store.type==1?'selected':''}>虚拟</option>
                                </select>
                            </div>
                        </div>
                        <!--虚拟物品礼物和道具区域-->
                        <div class="layui-form-item" id="prizeListArea" {$live_store.type==2?'style="display:none"':''}>
                            <label class="layui-form-label">礼物或道具选择</label>
                            <div class="layui-input-inline">
                                <select name="gift_props">
                                    <option value="">请选择</option>
                                    {notempty name="$gift_list"}
                                    <optgroup label="活动礼物">
                                        {volist name="gift_list" id="gvo"}
                                        <option value="gift_{$gvo.id}" {$live_store.gift_id==$gvo.id?'selected':''}>{$gvo.title}</option>
                                        {/volist}
                                    </optgroup>
                                    {/notempty}

                                    {notempty name="$props_list"}
                                    <optgroup label="道具">
                                        {volist name="props_list" id="pvo"}
                                        <option value="props_{$pvo.id}" {$live_store.props_id==$pvo.id?'selected':''}>{$pvo.name}</option>
                                        {/volist}
                                    </optgroup>
                                    {/notempty}
                                </select>
                            </div>
                        </div>

                        <div class="layui-form-item" id="goodsTitle" {$live_store.type==1?'style="display:none"':''}>
                            <label class="layui-form-label">商品名称</label>
                            <div class="layui-input-inline">
                                <input type="text" name="title" value="{$live_store.title}" placeholder="请输入" class="layui-input" lay-verify="">
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">商品图片</label>
                            <div class="layui-input-inline">
                                <input name="thumb" id="LAY_iconImgSrcProps" placeholder="图片地址" value="{$live_store.thumb}" class="layui-input" lay-verify="required">
                            </div>
                            <div class="layui-input-inline layui-btn-container" style="width: auto;">
                                <button type="button" class="layui-btn layui-btn-primary  LAY_iconImgUpload" lay-data="{idObjName: 'LAY_iconImgSrcProps'}">
                                    <i class="layui-icon">&#xe67c;</i>上传图片
                                </button>
                                <button class="layui-btn layui-btn-primary" layadmin-event="coverImgPreview" data-idname="LAY_iconImgSrcProps">查看图片</button>
                            </div>
                        </div>


                        <div class="layui-form-item  layui-hide">
                            <label class="layui-form-label">商品期限</label>
                            <div class="layui-input-inline">
                                <input type="text" name="limit" value="0" class="layui-input" placeholder="默认0为永久；1为24小时，依次类推" onkeyup="clearNoNum(this)" lay-verify="required">
                            </div>
                        </div>
                        <div class="layui-form-item layui-hide">
                            <label class="layui-form-label">贵族折扣</label>
                            <div class="layui-input-inline">
                                <input type="radio" value="1" name="vip_discount" title="是" checked/>
                                <input type="radio" value="2" name="vip_discount" title="否" />
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">宝石价格</label>
                            <div class="layui-input-inline">
                                <input type="text" name="diamond" value="{$live_store.diamond}" class="layui-input" placeholder="请输入数字，等于大于1,0为前端不展示" lay-verify="number" onkeyup="inputNum(this)">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">钻石价格</label>
                            <div class="layui-input-inline">
                                <input type="text" name="gold" value="{$live_store.gold}" class="layui-input" placeholder="请输入数字，等于大于1,0为前端不展示" lay-verify="number" onkeyup="inputNum(this)">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">商品排序</label>
                            <div class="layui-input-inline">
                                <input type="text" name="sort" value="{$live_store.sort}" class="layui-input" placeholder="请输入数字，等于大于1,1靠前，2靠后，依次类推" lay-verify="required|number" onkeyup="clearNoNum(this)">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">商品介绍</label>
                            <div class="layui-input-block">
                                <textarea class="layui-textarea" name="content" lay-verify="required" placeholder="请输入">{$live_store.content}</textarea>
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit="" lay-filter="livestore-edit">确认保存</button>
                            </div>
                        </div>
                    </div>

                </div>
            </div>
        </div>
    </div>
</div>

<script src="/layuiadmin/layui/layui.js"></script>
<script src="/assets/cos-js-sdk-v5/cos-js-sdk-v5.js"></script>
<script>
    layui.config({
        base: '/layuiadmin/' //静态资源所在路径
        , version: "{:config('other.ui_version')}"
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'live_store', 'form', 'admin'], function () {
        var $ = layui.$
            , admin = layui.admin
            , form = layui.form;

        var index = parent.layer.getFrameIndex(window.name);

        form.on('select(type_sel)', function (data) {
            if (data.value == 1) {
                $('#prizeListArea').show();
                $('#goodsTitle').hide();
                $('#goodsTitle input').val('')
            } else {
                $('#prizeListArea').hide();
                $('#goodsTitle').show();
            }
            // 清楚select选中项
            $('#prizeListArea option:selected').attr("selected", false);
            form.render();
        })

        form.on('submit(livestore-edit)', function (obj) {
            //提交
            layer.load();
            admin.req({
                url: '{:url("liveStore/edit")}'
                , data: obj.field
                , success: function (res) {
                    layer.closeAll("loading");
                    if (res.code == 0) {
                        parent.layer.close(index);
                        parent.layer.msg(res.msg, {icon: 1});
                        //bug fix: 操作人员设置完热度数值点击确定配置窗口没有消失的bug
                        parent.layui.table.reload('LAY-livestore-manage');
                    }
                },
                complete: function () {
                    layer.closeAll("loading");
                },
            });
        });


    });
</script>
</body>
</html>
